package com.jixiantubu.adapter;

import image.SmartImageView;

import java.util.ArrayList;
import java.util.List;

import com.example.jixiantubu.R;

import com.jixiantubu.bean.TupianBean;
import com.jixiantubu.tupianlunbo.MyPagerAdapter_fx;
import com.jixiantubu.util.MyApplication;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class Luntan_TuPianAdapter extends BaseAdapter {
	Context context;
	List<TupianBean> list = new ArrayList<TupianBean>();
	LayoutInflater mInflater;
	ViewHolder1 holder;
	private MyPagerAdapter_fx pageradapter;
	
	
	public Luntan_TuPianAdapter(Context context, List<TupianBean> list,
			MyPagerAdapter_fx pageradapter) {
		super();
		this.context = context;
		this.list = list;
		this.pageradapter = pageradapter;
		mInflater = LayoutInflater.from(context);
	}

	public List<TupianBean> getList() {
		return list;
	}

	public void setList(List<TupianBean> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		Log.e("论坛图片集合", list.toString());
		if (arg1 == null) {
			holder = new ViewHolder1();
			arg1 = mInflater
					.inflate(R.layout.luntan_tupian_gridview_item, null);
			holder.imageView = (SmartImageView) arg1
					.findViewById(R.id.luntan_tupian_imageview);
			/*holder.textView = (TextView) arg1
					.findViewById(R.id.luntan_tupian_textview);*/
			arg1.setTag(holder);

		} else {
			holder = (ViewHolder1) arg1.getTag();
		}
		String url = "http://" + MyApplication.getIP() + ":8080/Jinnang/img/"
				+ list.get(arg0).getPl_path();
		Log.e("!!!胡椒", url);
		holder.imageView.setstyle("fillet");
		holder.imageView.setImageUrl(url, R.drawable.error, R.drawable.loding);
		//holder.textView.setText(list.get(arg0).getTime());
		return arg1;
	}

}

class ViewHolder1 {
	SmartImageView imageView;
	//TextView textView;
}
